home *** CD-ROM | disk | FTP | other *** search
/ PC Play 129 / pc play 129.iso / Demo / man2 / man2.exe / data / scripts / submarine_scripts.lua < prev    next >
Encoding:
Text File  |  2006-08-31  |  6.5 KB  |  179 lines

  1.  
  2. function units_submarine_setup()
  3.     units_setup_sea(4,false,true,ENET_EFFECT_GEOMETRY_SUBMARINESHADOW)
  4.     units_reloadfirespots(uniGetExecutor(),1,ENET_EFFECT_SUBROCKET)
  5. end
  6.  
  7. function units_submarine_resetup()
  8.     units_setup_sea(4,false,false,ENET_EFFECT_GEOMETRY_SUBMARINESHADOW)
  9.     units_reloadfirespots(uniGetExecutor(),1,ENET_EFFECT_SUBROCKET)
  10. end
  11.  
  12. function units_submarine_select()
  13.     units_select(12,1)
  14. end
  15.  
  16. function units_submarine_unselect()
  17.     units_unselect()
  18. end
  19.  
  20. function units_submarine_selectenemy()
  21.     uniGetExecutor():addSimpleEffect(ENET_EFFECT_SELECTEDGEOMETRY_ENEMY)
  22. end
  23.  
  24. function units_submarine_damaged()
  25.     uniGetExecutor():applyDamage(uniGetLife())
  26. end
  27.  
  28. function units_submarine_highlight()
  29.     uniGetExecutor():addEffectWithRadius(ENET_EFFECT_GEOMETRY_HIGHLIGHT,15)
  30. end
  31.  
  32. function units_submarine_explode()
  33.     units_explode_water3()
  34. end
  35.  
  36. function units_submarine_fire()
  37.     local unit = uniGetExecutor()
  38.     uniSetLife(uniGetLife() / 4.0)
  39.     local gt = unit:getBone(ENBT_GUNNEST)
  40.     unit:play3DSound("submarine turn.wav",0)
  41.     waitDeath(unit:addRotationEffect(ENET_EFFECT_ROTATE_UNITTOTARGET,MATH_PI,uniGetTarget()))
  42.     local guns = {}
  43.      guns[0] = gt:getBone(ENBT_GUN,0)
  44.     guns[1] = gt:getBone(ENBT_GUN,1)
  45.     local rots = {}
  46.     rots[0] = guns[0]:addRotationEffect(ENET_EFFECT_ROTATE_WHEEL,-MATH_PI / 3.0,nil)
  47.     rots[1] = guns[1]:addRotationEffect(ENET_EFFECT_ROTATE_WHEEL,-MATH_PI / 3.0,nil)
  48.     pause(0.7)
  49.     rots[0]:destroy()
  50.     rots[1]:destroy()
  51.     local i
  52.     for i=0,3 do
  53.         local shot1
  54.         unit:findEffect(ENET_EFFECT_SUBROCKET):executeCommand(ENC_FIRE1)
  55.         if(i < 2) then
  56.         shot1 = guns[0]:addBulletEffect(ENET_EFFECT_PS_SUBMARINESHOT)
  57.         end
  58.         if(i > 1) then
  59.         shot1 = guns[1]:addBulletEffect(ENET_EFFECT_PS_SUBMARINESHOT)
  60.         end
  61.         pause(0.4)
  62.         shot1:suspendedDestroy(2.0)
  63.     end
  64.     units_reloadfirespots(uniGetExecutor(),1,ENET_EFFECT_SUBROCKET)
  65.     pause(1.0)
  66.     guns[0]:addRotationEffect(ENET_EFFECT_ROTATE_GUNTOWERDEFAULT,MATH_PI / 3.0)
  67.     guns[1]:addRotationEffect(ENET_EFFECT_ROTATE_GUNTOWERDEFAULT,MATH_PI / 3.0)
  68.     unit:addFireArrow()
  69. end
  70.  
  71. function units_submarine_move()
  72.     local unit = uniGetExecutor()
  73.     unit:play3DSound("submarine turn.wav",0)
  74.     waitDeath(unit:addRotationEffect(ENET_EFFECT_ROTATE_UNIT,MATH_PI * 0.6))
  75.     local wPos = unit:getWorldPosition()
  76.     wPos.y = wPos.y - 10
  77.     unit:play3DSound("submarine dive noise.wav",0)
  78.     waitDeath(unit:linearFly(wPos,10))
  79.     wPos = uniGetPosition()
  80.     wPos.y = wPos.y - 10
  81.     waitDeath(unit:addMoveEffect(ENET_EFFECT_MOVE_LINEAR,80))
  82.     wPos = unit:getWorldPosition()
  83.     wPos.y = wPos.y + 10
  84.     unit:play3DSound("submarine surface noise.wav",0)
  85.     waitDeath(unit:linearFly(wPos,10))
  86.     end
  87.  
  88. -- register functions to unit scriptset - they will be called when specified command arrives to unit
  89. registerCommand(ENSCRIPTSET_SUBMARINE,ENC_MOVE,"units_submarine_move")
  90. registerCommand(ENSCRIPTSET_SUBMARINE,ENC_FIRE1,"units_submarine_fire")
  91. registerCommand(ENSCRIPTSET_SUBMARINE,ENC_FIRE2,"units_submarine_fire")
  92. registerCommand(ENSCRIPTSET_SUBMARINE,ENC_SELECT,"units_submarine_select")
  93. registerCommand(ENSCRIPTSET_SUBMARINE,ENC_SELECTENEMY,"units_submarine_selectenemy")
  94. registerCommand(ENSCRIPTSET_SUBMARINE,ENC_UNSELECT,"units_submarine_unselect")
  95. registerCommand(ENSCRIPTSET_SUBMARINE,ENC_SETUP,"units_submarine_setup")
  96. registerCommand(ENSCRIPTSET_SUBMARINE,ENC_RESETUP,"units_submarine_resetup")
  97. registerCommand(ENSCRIPTSET_SUBMARINE,ENC_DAMAGED,"units_submarine_damaged")
  98. registerCommand(ENSCRIPTSET_SUBMARINE,ENC_EXPLODE,"units_submarine_explode")
  99. registerCommand(ENSCRIPTSET_SUBMARINE,ENC_HIGHLIGHT,"units_submarine_highlight")
  100.  
  101. -- make description of unit
  102. desc = getEffectDescriptionP(ENET_UNIT_SUBMARINE)
  103. desc.ClassID = ENCLASS_MESHINSTANCE
  104. desc.EffectClassType = ENECT_GEOMETRY
  105. desc.FileName = "submarine.rmd"
  106. desc.ScriptSet = ENSCRIPTSET_SUBMARINE
  107. --desc.MoveType = ENMOVE_SWIM
  108. desc.MoveType = ENMOVE_FLY
  109. desc.RenderType = ENRENDERTYPE_GEOMETRY
  110. desc.Material = ENMAT_RIGIDSKINNEDMESH
  111. desc.MaterialColors = units_materialcolors_human
  112.  
  113. -- shadow
  114. desc = getEffectDescriptionP(ENET_EFFECT_GEOMETRY_SUBMARINESHADOW)
  115. desc.ClassID = ENCLASS_MESHINSTANCE
  116. desc.EffectClassType = ENECT_GEOMETRY
  117. desc.FileName = "submarine_shadow.rmd"
  118. desc.RenderType = ENRENDERTYPE_SHADOW
  119. desc.Material = ENMAT_SHADOW
  120. desc.MaterialColors = units_materialcolors_shadow
  121.  
  122. -- register new unit to logic
  123. unitDesc = logic_getUnitDescP(33)
  124. unitDesc.group = 1
  125. unitDesc.order = 2
  126. unitDesc.unit_res_id = ENET_UNIT_SUBMARINE
  127. unitDesc.unit_icon_id = "Submarine_h_small_normal.dds"
  128. unitDesc.active_id = "Submarine_h_small_active.dds"
  129. unitDesc.pressed_id = "Submarine_h_small_pressed.dds"
  130. unitDesc.big_icon_id = "Submarine_h_big_normal.dds"
  131. unitDesc.small_icon_id = "Submarine_u_stats.dds"
  132. unitDesc.HP = 4
  133. unitDesc.MP = 50
  134. unitDesc.WR = 2
  135. unitDesc.min_WR = 2
  136. unitDesc.WD = 2
  137. unitDesc.WR2 = 0
  138. unitDesc.min_WR2 = 0
  139. unitDesc.WD2 = 0
  140. unitDesc.ability = 8
  141. unitDesc.transport = 0
  142. unitDesc.value = 3
  143. unitDesc.race = 0
  144. unitDesc.fire_pause = 0.6
  145. unitDesc.move_pause = 0.5
  146. unitDesc.unit_info_scale = 0.07
  147. unitDesc.scn_name = "SUBMARINE"
  148.  
  149.  
  150. ------------------------------------------------------------------------------------------------------
  151. ------------------------ effects related to unit------------------------------------------------------
  152. ------------------------------------------------------------------------------------------------------
  153.  
  154. function bullets_subrocket_fire()
  155.     local bullet = uniGetExecutor()
  156.     bullet:setTransformOwner()
  157.     bullet:play3DSound("bigrocket_rocket_start.wav",0)
  158.     waitDeath(bullet:addMoveEffect(ENET_EFFECT_MOVE_ROCKETSTART,110,uniGetTarget(),100.0))
  159.     local light = bullet:addSimpleEffect(ENET_EFFECT_LIGHT_ROCKETENGINE)
  160. --    local sound = bullet:play3DSound("bigrocket_rocket_fly.wav",1)
  161.     bullet:play3DSound("bigrocket_rocket_fly.wav",0)
  162.     local track = bullet:addSimpleEffect(ENET_EFFECT_PS_SUBMARINESHOT_FLY)
  163. --    waitDeath(bullet:addMoveEffect(ENET_EFFECT_MOVE_ROCKETFLYPARABOLA,150,uniGetTarget()))
  164.     waitDeath(bullet:parabolicFly(uniGetTarget()))
  165. --    sound:destroy()
  166.     light:destroy()
  167.     track:suspendedDestroy(3.0)
  168.     bullet:play3DSound("bigrocket_rocket_explode.wav",0)
  169.     bullet:setVisibility(false,true)
  170.     --bullet:addSimpleEffect(ENET_EFFECT_LIGHT_ROCKETEXPLODE):delayedDestroy(1.0)
  171.     --bullet:addSimpleEffect(ENET_EFFECT_PS_BIGROCKETEXPLODE):suspendedDestroy(1.0)
  172.     bullet:addSimpleEffect(ENET_EFFECT_PS_SUBMARINESHOT_EXPLOSION):suspendedDestroy(3.0)
  173.     uniGetTarget():executeCommand(ENC_DAMAGED)
  174.     pause(1.0)
  175.     bullet:suspendedDestroy(3.0)
  176. end
  177.  
  178. --registerCommand(ENSCRIPTSET_SUB_ROCKET,ENC_FIRE1,"bullets_subrocket_fire")
  179.